#!/bin/bash
# 说明：集群root用户免密登录
# by: jiwei
hosts=(
    "root@172.31.0.9"
    "root@172.31.0.10"
    "root@172.31.0.11"
    "root@172.31.0.12"
    "root@172.31.0.13"
    "root@172.31.0.14"
    "root@172.31.0.15"
    "root@172.31.0.16"
)

if [ ! -f ~/.ssh/id_rsa.pub ]; then
    ssh-keygen -t rsa -N '' -f ~/.ssh/id_rsa
fi

for host in "${hosts[@]}"; do
    ssh-copy-id $host > /dev/null 2>&1
done
